package com.giw.project.file_manager;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintStream;
import java.net.MalformedURLException;

public class FilmWithoutGenre {

	public static void main(String[] args) {

		File f1 = new File("files/tuttiFilm.txt");
		File f2 = new File("files/filmcongenere.txt");

		try {
			boolean flag = false;
			FileInputStream fis1 = new FileInputStream(f1);

			InputStreamReader isr1 = new InputStreamReader(fis1);

			BufferedReader br1 = new BufferedReader(isr1);

			FileOutputStream file = new FileOutputStream("files/file.txt");
			PrintStream Output = new PrintStream(file);

			String linea1 = br1.readLine();

			while (linea1 != null) {
				FileInputStream fis2 = new FileInputStream(f2);
				InputStreamReader isr2 = new InputStreamReader(fis2);
				BufferedReader br2 = new BufferedReader(isr2);
				String linea2 = br2.readLine();
				while (linea2 != null && !flag) {
					if (linea1.equals(linea2)) {
						flag = true;
					}
					linea2 = br2.readLine();
				}

				if (!flag)
					Output.println(linea1);
				linea1 = br1.readLine();
				br2.close();
				isr2.close();
				fis2.close();
				flag = false;

			}
		}

		catch (MalformedURLException e) {
			System.out.println("Attenzione:" + e);
		} catch (IOException e) {
			System.out.println(e.getMessage());
		}

	}

}
